package org.rslai.autotest.core.page;

import org.openqa.selenium.WebDriver;
import org.rslai.autotest.core.driver.IDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

/**
 * page对象的基类
 * @author rslai
 */
@ContextConfiguration(locations = "classpath:cucumber.xml")
public abstract class AbstractPageObject {
	@Autowired
	protected IDriver iDriver;

	@Autowired
	protected Conf conf;

	@Autowired
	protected Navigate navigate;

	@Autowired
	protected Wait wait;

	@Autowired
	protected Click click;

	@Autowired
	protected Select select;

	@Autowired
	protected Checkbox checkbox;

	@Autowired
	protected SendKeys sendkeys;

	@Autowired
	protected SpringContext springContext;

	@Autowired
	protected Frame frame;

	@Autowired
	protected Assertions assertions;

	@Autowired
	protected Table table;

	@Autowired
	protected Window window;

	@Autowired
	protected Email email;

	@Autowired
	protected Alert alert;

	@Autowired
	protected Script script;

	@Autowired
	protected Actions actions;

	@Autowired
	protected Robot robot;

	@Autowired
	protected UploadFile uploadFile;

	@Autowired
	protected AutoIt autoIt;

	@Autowired
	protected Compress compress;

	@Autowired
	protected Image image;

	@Autowired
	protected ScreenShot screenShot;

	@Autowired
	protected Cookie cookie;

	/**
	 * 返回当前 WebDriver
	 * @return 返回WebDriver
	 */
	protected WebDriver driver() {
		return iDriver.getDriver();
	}

	/**
	 * 强制 sleep 指定秒数
	 * @param seconds 秒
	 */
	protected void sleep(double seconds) {
		org.rslai.util.time.Time.getInstance().sleep(seconds);
	}

	/**
	 * Frame切换，抽象方法
	 */
	protected abstract void switchToFrame();

}
